import { getAreaObj, uploadType } from '@/utils/util'

export const formConfig = {
	inline: false,
	showBtn: true,
	labelPosition: 'top',
	labelWidth: '120px',
	column: [
		{
			label: '演练名称',
			prop: 'drillTitle',
			type: 'input',
			rules: [{ required: true, message: '请选择演练名称' }],
			span: 8,
		},
		{
			label: '演练时间',
			prop: 'drillTime',
			type: 'date',
			format: 'YYYY年MM月DD日',
			valueFormat: 'YYYY-MM-DD',
			rules: [{ required: true, message: '请选择演练时间' }],
			span: 8,
		},
		{
			label: '参与方',
			prop: 'partyLabel',
			type: 'input',
			span: 8,
		},
		{
			label: '演练内容',
			prop: 'drillContent',
			type: 'textarea',
			maxlength: '500',
			showWordLimit: true,
			autosize: {
				minRows: 1,
			},
			span: 24,
		},
		{
			label: '演练记录及图片',
			prop: 'drillPhoto',
			type: 'upload',
			listType: 'picture-card',
			labelPosition: 'top',
			showFileList: true,
			limit: 4,
			multiple: true,
			changeField: true,
			span: 24,
			rules: [{ required: true, message: '请上传演练记录及图片' }],
		},
		{
			label: '签字照片',
			tip: '',
			prop: 'signaturePic',
			type: 'upload',
			labelPosition: 'top',
			showFileList: false,
			limit: 1,
			multiple: false,
			span: 24,
		},
	],
}

export const searchConfig = {
	inline: true,
	showBtn: true,
	labelPosition: 'left',
	column: [
		{
			label: '所属地区',
			prop: 'areas',
			type: 'AplidAreaSelect',
			span: 8,
		},
		{
			label: '所属单位',
			prop: 'organizationName',
			type: 'input',
			span: 8,
		},
		{
			label: '演练名称',
			prop: 'drillTitle',
			type: 'input',
			span: 8,
		},
		{
			label: '演练时间',
			prop: 'drillTime',
			type: 'date',
			format: 'YYYY年MM月DD日',
			valueFormat: 'YYYY-MM-DD',
			span: 8,
		},
		{
			label: '演练内容',
			prop: 'drillContent',
			type: 'input',
			span: 8,
		},
		{
			label: '参与方',
			prop: 'partyLabel',
			type: 'input',
			span: 8,
		},
	],
}

export const tableConfig = {
	stripe: true,
	border: true,
	columns: [
		{ label: '所属区', prop: 'areaName' },
		{ label: '所属单位', prop: 'organizationName' },
		{ label: '演练名称', prop: 'drillTitle' },
		{ label: '演练时间', prop: 'drillTime' },
		{
			label: '演练内容',
			prop: 'drillContent',
		},
		{ label: '参与方', prop: 'partyLabel' },
		{
			label: '操作',
			prop: 'menu',
			width: 300,
			fixed: 'right',
		},
	],
}

export const api = {
	index: 'view_pbFireDrill_page',
	add: 'view_pbFireDrill_add',
	edit: 'view_pbFireDrill_edit',
	delete: 'view_pbFireDrill_del',
	export: 'view_pbFireDrill_export',
  detail:'view_pbFireDrill_view',
	authArea: 'authArea',
}
export const baseConfig = {
	pageName: '消防演练记录',
	dictcodes: ['INSPECTION_CONTENT'],
	rowKey: 'id',
	addLabel: '新增',
	tipLabel: 'drillTitle',
	exportMqTopic: '/ning/export/',
	loadOrgInfo: true,
	api,
	auth: {
		...api,
		mulitSet: 'mulitSet',
	},
	paramsObj: {
		source: 1,
	},
	menuBtn: [
		{
			icon: 'editor',
			label: '编辑',
			type: 'primary',
			operate: 'edit',
			auth: api.edit,
			text: true,
			show: true,
		},
		{
			icon: 'detail',
			label: '详情',
			type: 'primary',
			operate: 'detail',
			auth: api.index,
			text: true,
			show: true,
		},
		{
			icon: 'delete',
			label: '删除',
			type: 'danger',
			operate: 'delete',
			auth: api.delete,
			text: true,
			show: true,
		},
	],
	dialogConfig: {
		width: '55%',
	},
	searchConfig,
	formConfig,
	tableConfig,
	detailConfig: formConfig,
	beforeOnLoadFormate: async (params) => {
		return new Promise((resolve, reject) => {
			const areaObj: any = getAreaObj(params.areas)
			resolve({
				...params,
				...areaObj,
				areas: undefined,
			})
		})
	},
}
